<div class="pageHeader">
	<form class="pagerForm" method="post" onsubmit="return navTabSearch(this);" action="<?cs var:config.cgipath?>mt_slog_machine?action=search">
		<?cs include:config.cspath+"dmt_page_para.html" ?>
		<input type="hidden" name="dm_keyword" value="<?cs var:config.dm_keyword ?>" />
		<input type="hidden" name="dm_machine_id" value="<?cs var:config.dm_machine_id ?>" />
		<input type="hidden" name="dm_machine_ip" value="<?cs var:config.dm_machine_ip ?>" />
		<input type="hidden" name="dm_machine_warn_flag_list" value="<?cs var:config.dm_machine_warn_flag ?>" />
	</form>

	<form onsubmit="return navTabSearch(this, 'dmt_machine');" action="<?cs var:config.cgipath?>mt_slog_machine?action=search">
		<div class="searchBar">
			<ul class="searchContent" >
				<li class="width:auto">
					<label>机器ID:</label><input type="text" name="dm_machine_id" size="10" value="<?cs var:config.dm_machine_id?>" />
				</li>
				<li class="width:auto">
					<label>机器IP:</label><input type="text" name="dm_machine_ip" size="16" value="<?cs var:config.dm_machine_ip ?>" />
				</li>
				<li class="width:auto">
					<label>告警标记:</label>
					<select class='xrk_combox' name="dm_machine_warn_flag_list" id="dm_machine_warn_flag_list">
						<option value="0">全部</option>
						<option value="<?cs var:config.dmm_mach_allow_all ?>">不屏蔽</option>
						<option value="<?cs var:config.dmm_mach_deny_all ?>">完全屏蔽</option>
					</select>
				</li>
			</ul>
			<div class="subBar">
				<ul>
					<li class="width:auto"><button type="submit" class="buttonActive"><i class='icon-search icon-large '></i>查找</button></li>
					<li><button class="buttonActive" id="dm_btn_erase" ><i class="icon-trash icon-large"></i>重填</button></li>
				</ul>
			</div>
		</div>
	</form>
</div>
		
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li><a href="<?cs var:config.cgipath?>mt_slog_machine?action=add&navTabId=dmt_machine" target="dialog" mask="true" maxable="false" resizable="false" width="520" height="460" title="添加上报机器"><i class='icon-plus'></i>添加</a></li>
			<li class="line">line</li>

			<li><a href="<?cs var:config.cgipath?>mt_slog_machine?action=delete&id={machine_id}&navTabId=dmt_machine" target="ajaxTodo" title="确定要删除吗?"><i class='icon-minus'></i>删除</a></li>
			<li class="line">line</li>

			<li><a href="<?cs var:config.cgipath?>mt_slog_machine?action=mod&id={machine_id}&navTabId=dmt_machine" target="dialog" mask="true" maxable="false" resizable="false" width="520" height="460" title="修改机器配置"><i class='icon-edit'></i>修改</a></li>
			<li class="line">line</li>

			<li><a href="<?cs var:config.cgipath?>mt_slog_machine?action=machine_add_plugin&id={machine_id}&navTabId=dmt_machine" target="navTab" title="插件部署"><i class='icon-edit'></i>插件部署</a></li>
			<li class="line">line</li>
		</ul>
	</div>

	<table class="list" width="100%" layoutH="0">
		<thead>
			<tr>
				<th width='20'>序号</th>
				<th width='25'>机器id</th>
				<th width='80'>机器名称</th>
				<th width='60'>机器IP</th>
				<th width='60'>机器IP2</th>
				<th width='50'>告警标记</th>
				<th width='50'>上报状态</th>
				<th width='100'>机器描述</th>
				<th width='60'>机器状态</th>
			</tr>
		</thead>
		<tbody id="dm_machine_info_list">
		</tbody>
	</table>
	<?cs include:config.cspath+"dmt_page.html" ?>
</div>

<script language="javascript" type="text/javascript">
var dm_machine_info = <?cs var:config.machine_info ?>;

function dmSetMachineList(machine_info)
{
	var list = "";
	var list_machine = machine_info.list;
	for(var i=0,j=0; i < machine_info.count && i < list_machine.length; i++)
	{
		list += "<tr target='machine_id' rel='" + list_machine[i].id + "'>";
		j = (<?cs var:config.currentPage ?>-1) * <?cs var:config.numPerPage ?> + 1;
		list += "<td>" + (i+j) + "</td>";
		list += "<td>" + list_machine[i].id + "</td>";
		list += "<td>" + list_machine[i].name + "</td>";

		list += "<td>" + list_machine[i].ip + "</td>";
		if(typeof list_machine[i].ip2 != "undefined")
			list += "<td>" + list_machine[i].ip2 + "</td>";
		else
			list += "<td></td>";
		if(list_machine[i].warn_flag == <?cs var:config.dmm_mach_deny_all ?>)
			list += "<td><span class='xrk_warn_mask'>已屏蔽</span></td>";
		else 
			list += "<td><span class='xrk_text_bl'>正常</span></td>";

        if(list_machine[i].rep_status == 3)
			list += "<td title='最近一小时无心跳无数据上报'><span class='xrk_show_txt_hs'>长时间离线</span></td>";
        else if(list_machine[i].rep_status == 2)
			list += "<td title='最近5分钟有数据上报'><span class='xrk_text_bl'>数据上报中</span></td>";
        else if(list_machine[i].rep_status == 1)
            list += "<td title='可能是未安装agent 或者agent 运行异常'><span class='xrk_show_txt_hs'>无心跳</span></td>";
        else 
            list += "<td title='最近3分钟无数据上报但有心跳消息'><span class='xrk_text_bl2'>心跳正常</span></td>";
		list += "<td>" + list_machine[i].desc + "</td>";

		list += "<td><a class='detail' href='<?cs var:config.cgipath?>mt_slog_machine?action=show_status&id=";
        list += list_machine[i].id + "&navTabId=dmt_machine' target='navTab'";
        list += ' rel="machine_status_' + list_machine[i].id + '" title="查看机器状态">查看</a>';
        list += '</td>';
		list += "</tr>";
	}
	return list;
}

$(document).ready(function(){
	var machine_info = dmSetMachineList(dm_machine_info);
	var machine = $("#dm_machine_info_list");
	machine.html(machine_info);

	$("select[name=numPerPage] option").each(function(){
		if(this.value == <?cs var:config.numPerPage ?>)
			$(this).attr("selected", true);
	});

	<?cs if:config.dm_machine_warn_flag ?>
	$("#dm_machine_warn_flag_list").children("option").each(function(){
		if(<?cs var:config.dm_machine_warn_flag ?> == $(this).val())
			$(this).attr("selected", true);
	});
	<?cs /if ?>

	$("#dm_btn_erase").click(function(){
		$("input[name=dm_keyword]").val("");
		$("input[name=dm_machine_id]").val("");
		$("input[name=dm_machine_ip]").val("");
		$("select[name=dm_machine_warn_flag_list]").val(0);
		return false;
	});
});

</script>

